<script setup lang="ts">
import { api_url } from '@/api/api'
import { useParameterstore } from '@/stores/parameter'
import { useStandardstore } from '@/stores/standard'
import { storeToRefs } from 'pinia'

const parameterstore = useParameterstore()
const parameter = storeToRefs(parameterstore).parameter
const standardstore = useStandardstore()
const standard = standardstore.standard

function toFile(x: string) {
  window.open(api_url + 'files/' + x)
}
</script>

<template>
  <div class="ry">
    <div class="title_sub">
      <span class="text_sub"> 人员 </span>
    </div>
    <el-table :data="parameter.humanList">
      <el-table-column type="index"></el-table-column>
      <el-table-column label="姓名" prop="information"></el-table-column>
      <el-table-column label="培训情况">
        <template #default="scope">
          <el-link v-if="scope.row.trainFile != ''" @click="toFile(scope.row.trainFile)">{{
            scope.row.trainFile
          }}</el-link>
          <span v-else>无</span>
        </template>
      </el-table-column>
      <el-table-column label="考核资料">
        <template #default="scope">
          <el-link v-if="scope.row.examineFile != ''" @click="toFile(scope.row.examineFile)">{{
            scope.row.examineFile
          }}</el-link>
          <span v-else>无</span>
        </template>
      </el-table-column>
      <el-table-column label="授权批准">
        <template #default="scope">
          <el-link
            v-if="scope.row.authorizationFile != ''"
            @click="toFile(scope.row.authorizationFile)"
            >{{ scope.row.authorizationFile }}</el-link
          >
          <span v-else>无</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
  <div class="sb">
    <div class="title_sub">
      <span class="text_sub"> 设备 </span>
    </div>
    <el-table :data="parameter?.equipmentList">
      <el-table-column type="index"></el-table-column>
      <el-table-column label="设备仪器编号" prop="equipNo"></el-table-column>
      <el-table-column label="名称" prop="name"></el-table-column>
      <el-table-column label="型号/规格/等级" prop="level"></el-table-column>
      <el-table-column label="测量范围" prop="scope"></el-table-column>
      <el-table-column label="设备购买年份" prop="addYear"></el-table-column>
      <el-table-column label="溯源方式" prop="traceMethod"></el-table-column>
      <el-table-column label="有效期截止至"></el-table-column>
      <el-table-column label="设备来源" prop="source"></el-table-column>
    </el-table>
  </div>
  <div class="yp">
    <div class="title_sub">
      <span class="text_sub"> 样品 </span>
    </div>
    <div v-if="parameter.sample.followStandard">当前为该标准通用样品</div>
    <div v-else>当前为本参数专用样品</div>
    <div style="display: flex">
      <div>样品信息一览表：</div>
      <el-link
        v-if="parameter.sample.informationFile != '' && !parameter.sample.followStandard"
        @click="toFile(parameter.sample.informationFile)"
        >{{ parameter?.sample.informationFile }}</el-link
      >
      <el-link
        v-else-if="standard.sample.informationFile != '' && parameter.sample.followStandard"
        @click="toFile(standard.sample.informationFile)"
        >{{ standard.sample.informationFile }}</el-link
      >
      <span v-else> 无文件 </span>
    </div>
    <div style="display: flex">
      <div>样品照片：</div>
      <el-link
        v-if="parameter.sample.photo != '' && !parameter.sample.followStandard"
        @click="toFile(parameter.sample.photo)"
        >{{ parameter.sample.photo }}</el-link
      >
      <el-link
        v-else-if="standard.sample.photo != '' && parameter.sample.followStandard"
        @click="toFile(standard.sample.photo)"
        >{{ standard.sample.photo }}</el-link
      >
      <span v-else> 无文件 </span>
    </div>
  </div>
  <div class="sop">
    <div class="title_sub">
      <span class="text_sub"> 检验细则(SOP) </span>
    </div>
    <div class="form_sop">
      <div v-if="parameter.sop.followStandard">当前为该标准通用SOP</div>
      <div v-else>当前为本参数专用SOP</div>
      <div style="display: flex">
        <div>检验细则：</div>
        <el-link
          v-if="parameter.sop.file != '' && !parameter.sop.followStandard"
          @click="toFile(parameter.sop.file)"
          >{{ parameter.sop.file }}</el-link
        >
        <el-link
          v-else-if="standard.sop.file != '' && parameter.sop.followStandard"
          @click="toFile(standard.sop.file)"
          >{{ standard.sop.file }}</el-link
        >
        <span v-else> 无文件 </span>
      </div>
    </div>
  </div>
  <div class="ss">
    <div class="title_sub">
      <span class="text_sub"> 设施 </span>
    </div>
    <el-table v-if="parameter.facilityList.length != 0" :data="parameter.facilityList">
      <el-table-column type="index"></el-table-column>
      <el-table-column label="要求名称" prop="name"></el-table-column>
      <el-table-column label="证明文件">
        <template #default="scope">
          <el-link v-if="scope.row.file != ''" @click="toFile(scope.row.file)">{{
            scope.row.file
          }}</el-link>
          <span v-else>无</span>
        </template>
      </el-table-column>
    </el-table>
    <div v-else>无特殊要求</div>
  </div>
  <div class="yz">
    <div class="title_sub">
      <span class="text_sub"> 比对验证 </span>
    </div>
    <el-table v-if="parameter.compareValidList.length != 0" :data="parameter.compareValidList">
      <el-table-column type="index"></el-table-column>
      <el-table-column label="比对/验证结果">
        <template #default="scope">
          <el-link v-if="scope.row.file != ''" @click="toFile(scope.row.file)">{{
            scope.row.file
          }}</el-link>
        </template>
      </el-table-column>
    </el-table>
    <div v-else>无特殊要求</div>
  </div>
  <div class="sy">
    <div class="title_sub">
      <span class="text_sub"> 模拟实验 </span>
    </div>
    <div class="form_sy">
      <div v-if="parameter.simulation.followStandard">当前为该标准通用模拟实验</div>
      <div v-else>当前为本参数专用模拟实验</div>
      <div style="display: flex">
        <div>模拟实验报告：</div>
        <el-link
          v-if="parameter.simulation.report != '' && !parameter.simulation.followStandard"
          @click="toFile(parameter.simulation.report)"
          >{{ parameter.simulation.report }}</el-link
        >
        <el-link
          v-else-if="standard.simulation.report != '' && parameter.simulation.followStandard"
          @click="toFile(standard.simulation.report)"
          >{{ standard.simulation.report }}</el-link
        >
        <span v-else> 无文件 </span>
      </div>
      <div style="display: flex">
        <div>原始记录：</div>
        <el-link
          v-if="parameter.simulation.origin != '' && !parameter.simulation.followStandard"
          @click="toFile(parameter.simulation.origin)"
          >{{ parameter.simulation.origin }}</el-link
        >
        <el-link
          v-else-if="standard.simulation.origin != '' && parameter.simulation.followStandard"
          @click="toFile(standard.simulation.origin)"
          >{{ standard.simulation.origin }}</el-link
        >
        <span v-else> 无文件 </span>
      </div>
    </div>
  </div>
</template>

<style scoped>
.title_sub {
  border-style: inset;
  border-color: black;
  border-top: 0;
  border-left: 0;
  border-right: 0;
  padding-bottom: 10px;
  margin-right: 50px;
  margin-bottom: 10px;
  margin-top: 10px;
}

.text_sub {
  font-size: 24px;
  font-weight: 800;
}
</style>
